Move test directory out of package path#168
Conversation
|
cc @jrfnl What do you think about this organization? |
jrfnl
left a comment
There was a problem hiding this comment.
Definitely a good step in the right direction. 👍
Next step, IMO, would be to split the VariableAnalysisTest.php into separate files, linked one-on-one with the fixture files.
Couple of small remarks/questions for this PR:
- Should the
fixturesdirectory be under thetests/Sniffsdirectory ? Or should theVariableAnalysisTest.phpfile possibly not be in aSniffssubdirectory ?
Having them as "equal" subdirectories seem to create a disconnect in their relation to each other. - As you're changing the
phpcs.xml.distruleset, shouldvendorbe excluded as well ?
Agreed.
Yes, good point. I'm not sure why I had moved it up a level. As for the
👍 One last thing to consider is the test namespace fixed in #164. This leaves that change in place, but I'm not sure if it's still correct. |
Good point, that will need fixing now. Would you like me to guide you through possible solutions or shall I add a commit to this branch with a fix ? |
|
You're welcome to commit to this branch! |
1. Make the namespace of the `VariableAnalysisTest` file reflect the path the file.
2. Add an `autoload-dev` section to the `composer.json`
* The unit tests are not shipped in the distribution package, so they are only available in a `dev` environment, which is exactly what `autoload-dev` is targetting.
* Setting the `tests` directory as a secondary path for PSR4 autoload should fix compatibility with Composer 2.
3699e8c to
4fba748
Compare
Done, the additional commit should fix it. See the commit message for the rationale. There's just one thing left I'm still a bit unsure about: the naming of the Especially with an eye of the test file being split in the future, would it make sense to call the directory That would also allow for additional sniffs - if the sniff would be split or other variable analysis sniffs would be added - to each have their own |
|
Oh... last thing which just popped up in my mind: should the |
Perfect. Thank you! 👌
Yeah, the directories were just set up to mirror the ones in the source directories, but I don't know why I chose to do that (presumably I was copying an existing structure somewhere). I think
That's a good question. My habit from other packages and languages is to leave everything lowercase unless required, hence |
Well, if it would mirror the
The only reason I can think of, is that having the actual tests in a subdirectory vs the test utility files (base test case + bootstrap) in the Is that enough of a reason ?
I'm thinking more of PSR-4 and the different OSes. The base namespace for the tests is Also - though a PHPCS requirement - the |
Sounds good to me! I'll move it shortly.
Good points, all. Thanks for leading me through the logic there. I'll rename it! |
Co-Authored-By: Juliette <663378+jrfnl@users.noreply.github.com>
* Move tests directory to top level
* Modify tests directory path in other files
* Move fixtures back adjacent to tests
* Exclude vendor from phpcs
* Tests: fix composer autoload
1. Make the namespace of the `VariableAnalysisTest` file reflect the path the file.
2. Add an `autoload-dev` section to the `composer.json`
* The unit tests are not shipped in the distribution package, so they are only available in a `dev` environment, which is exactly what `autoload-dev` is targetting.
* Setting the `tests` directory as a secondary path for PSR4 autoload should fix compatibility with Composer 2.
* Rename tests/Sniffs to tests/VariableAnalysisSniff
* Rename tests to Tests
* Rename Tests directory paths in files
* Rename test namespace to match new path
* Update .gitattributes from tests to Tests
Co-Authored-By: Juliette <663378+jrfnl@users.noreply.github.com>
Co-authored-by: jrfnl <jrfnl@users.noreply.github.com>
Co-authored-by: Juliette <663378+jrfnl@users.noreply.github.com>
This moves the tests from
VariableAnalysis/TeststoTests.Related to #116 and #162